package com.gmail.bloim.serg.t1006;

import static com.gmail.bloim.serg.t1006.Direction.*;

/**
 * User: Администратор
 * Date: 28.04.13
 * Time: 15:39
 */
enum Symbol {
    LT(UP, RIGHT), LB(LEFT, UP), RT(RIGHT, DOWN), RB(DOWN, LEFT), V(UP, UP), H(LEFT, LEFT);
    private final Direction defaultOut;
    private final Direction defaultIn;
    private final Direction secondaryIn;
    private final Direction secondaryOut;

    Symbol(Direction defaultIn, Direction defaultOut) {
        this.defaultOut = defaultOut;
        this.defaultIn = defaultIn;
        this.secondaryIn = defaultOut.getNegative();
        this.secondaryOut = defaultIn.getNegative();
    }


    public static Symbol getByChar(char ch) {
        switch (ch) {
            case 218:
                return LT;
            case 192:
                return LB;
            case 191:
                return RT;
            case 217:
                return RB;
            case 179:
                return V;
            case 196:
                return H;
        }
        return null;
    }

    public Direction forward(Direction prevDir) {
        if (prevDir == defaultIn)
            return defaultOut;
        if (prevDir == secondaryIn)
            return secondaryOut;
        return null;
    }

    public Direction getDefaultOut() {
        return defaultOut;
    }

    Direction getSecondaryOut() {
        return secondaryOut;
    }
}
